This tutorial describes how to configure Xcode in order to develop external objects for the Pure Data (Pd) programming language and covers build settings, debugging, and new target creation. It was written using an older version of Xcode for a presentation at ICMC 2010, but the settings have not changed.

Prerequisites
Download
Pure Data.zip - downloadable Xcode project with object examples ICMC 2010 · Pd Object Programming

Project Settings
1. Create a new project in Xcode. To do so select File -> New Project... from the menu bar.



2. Select the "BSD C Library" template by clicking Framework & Library -> BSD C Library.



3. Name and save the project.



4. Select the project's target and edit its information. To do so click the target to highlight it then select File -> Get Info to open the target's inspector.



5. Change the target's name to "obj1" — this example will be using the obj1.c file included with Pd vanilla.



6. Click the build tab then set Configuration to "All Configurations" by clicking the drop-down menu in the upper left corner of the dialog box.



7. Set several attributes of the target:







8. Exit the target's inspector, highlight the Source folder by clicking it, then make a new file by selecting File -> New File from the menu bar.



9. Make a new C file.



10. Name the new file obj1.c and uncheck Also create "obj1.h".



11. Copy the code from Pd's obj1.c file into the obj1.c file you just created. The file is located at /Applications/Pd-0.42-5.app/Contents/Resources/doc/6.externs/obj1.c.



12. Save the file, then set the project's processor architecture to i386 (assuming you have an intel mac), by selecting Project -> Set Active Architecture -> i386.



13. Build the target by selecting Build -> Build from the menu bar.



14. Open Pd and instantiate obj1, verifying its output in the Pd window.



Debugger Configuration
1. Create a new custom executable by selecting Project -> New Custom Executable from the menu bar.



2. Choose a name for the executable and set Executable Path: to /Applications/Pd-0.42-5.app/Contents/Resources/bin/pd.



3. Set a breakpoint. In this example line 17 will break on float input.



4. Debug the target by selecting Build -> Build and Debug - Breakpoints On from the menu bar.



5. Once Pd opens, instantiate obj1 and send it a float to trigger the breakpoint. Clicking the green continue button in Xcode will resume Pd's execution.



New Target Creation
1. Click the current target to highlight it, then select Edit -> Duplicate from the menu bar.



2. Click the new target to highlight it, then select File -> Get Info from the menu bar.



3. Rename the new target to a name of your choice. This example will use the arbitrary name "object".



4. Click the Build tab and change the Product Name to match the name from step 3 (i.e. "object"). Close the inspector when finished.



5. Click the Source folder to Highlight it, then select File -> New File... from the menu bar.



6. Create a new C file.



7. Name the new file to match the new target name (i.e. "object.c") and uncheck Also create "object.h". In the Targets: pane uncheck the old target "obj1" and check the new target "object".



8. Add code to the new file and compile when finished.